CREATE Procedure StoreNuke_CustomerUpdate
(
    @CustomerID int,
    @FirstName   nvarchar(50),
    @LastName   nvarchar(50),
    @Email      nvarchar(50),
    @Password   nvarchar(50),
    @IsAdmin   bit
)
AS

If @Password = ''

UPDATE StoreNuke_Customers
SET
    FirstName = @FirstName,
    LastName = @LastName,
    EmailAddress = @Email,
    IsAdmin = @IsAdmin
WHERE
    CustomerID = @CustomerID
    
Else

UPDATE StoreNuke_Customers
SET
    FirstName = @FirstName,
    LastName = @LastName,
    EmailAddress = @Email,
    Password = @Password,
    IsAdmin = @IsAdmin
WHERE
    CustomerID = @CustomerID

GO

CREATE PROC StoreNuke_UpdatePrimaryCustomerAddress
(
        @CustomerID int ,
        @ATTN nvarchar (50) ,
        @Address1 nvarchar (50) ,
        @Address2 nvarchar (50) ,
        @City nvarchar (20) ,
        @RegionCode char (2) ,
        @CountryCode char (2) ,
        @PostalCode nvarchar (10) ,
        @Phone1 nvarchar (20) ,
        @Phone2 nvarchar (20)
)
AS
UPDATE StoreNuke_Addresses
SET
        ATTN = @ATTN,
        Address1 = @Address1,
        Address2 = @Address2,
        City = @City,
        RegionCode = @RegionCode,
        CountryCode = @CountryCode,
        PostalCode = @PostalCode,
        Phone1 = @Phone1,
        Phone2 = @Phone2
WHERE
        CustomerID = @CustomerID And
        PrimaryAddress = 1
GO
